/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package intelligenttm.ITMCarto;

import Data.ExcelOperator;
import Data.ThematicData;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;

/**
 *
 * @author 望舒凌霄
 */
public class BaseData {
    private String DataName;
    private String DataPath;
    private String DataType;
    private ThematicData Data;

    public BaseData() {
    }
    
    
    public BaseData(String DataName, String DataPath, String DataType, ThematicData tData) {
        this.DataName = DataName;
        this.DataPath = DataPath;
        this.DataType = DataType;
        this.Data = tData;
    }

    public BaseData(String DataName, String DataPath, String DataType, String[][] tData) {
        this.DataName = DataName;
        this.DataPath = DataPath;
        this.DataType = DataType;
        this.Data = new ThematicData(tData);
    }

    public BaseData(String PathStr) throws IOException, FileNotFoundException, InvalidFormatException {
        File file=new File(PathStr);
        String[][] tData;
        tData=ExcelOperator.getData(file);
        Data=new ThematicData(tData);
        DataPath = file.getPath();
        String FileName=file.getName();
        int i = FileName.lastIndexOf(".");
        if(i>-1 && i<FileName.length()){
            DataName = FileName.substring(0, i); //--文件名
            DataType = FileName.substring(i+1); //--扩展名
        }
    }
    
    public BaseData(File file) throws IOException, FileNotFoundException, InvalidFormatException {
        String[][] tData;
        tData=ExcelOperator.getData(file);
        Data=new ThematicData(tData);
        DataPath = file.getPath();
        String FileName=file.getName();
        int i = FileName.lastIndexOf(".");
        if(i>-1 && i<FileName.length()){
            DataName = FileName.substring(0, i); //--文件名
            DataType = FileName.substring(i+1); //--扩展名
        }
    }

    public String getDataName() {
        return DataName;
    }

    public void setDataName(String DataName) {
        this.DataName = DataName;
    }

    public String getDataPath() {
        return DataPath;
    }

    public void setDataPath(String DataPath) {
        this.DataPath = DataPath;
    }

    public String getDataType() {
        return DataType;
    }

    public void setDataType(String DataType) {
        this.DataType = DataType;
    }

    public ThematicData getData() {
        return Data;
    }

    public void setData(ThematicData Data) {
        this.Data = Data;
    }
    
    public void setData() throws IOException, FileNotFoundException, InvalidFormatException {
        File file=new File(DataPath);
        String[][] tData;
        tData=ExcelOperator.getData(file);
        Data=new ThematicData(tData);
    }
    
    public void setData(String[][] tData) {
        Data=new ThematicData(tData);
    }
    
    public void setData(String TDataPath) throws IOException, FileNotFoundException, InvalidFormatException {
        File file=new File(TDataPath);
        String[][] tData;
        tData=ExcelOperator.getData(file);
        Data=new ThematicData(tData);
    }
}
